﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Ex03.GarageLogic
{
    public abstract class ElectricVehicle : Vehicle
    {
        private float m_BatteryHoursLeft;
        private float m_MaxBatteryHours;

        public float BatteryHoursLeft
        {
            get { return m_BatteryHoursLeft; }
        }

        public float MaxBatteryHours
        {
            get { return m_MaxBatteryHours; }
        }

        public override float LeftEnergyPercent
        {
            get { return BatteryHoursLeft * 100 / MaxBatteryHours; }
        }

        /// <summary>
        /// Charges the battery of the vehicle with the given number of hours.
        /// </summary>
        /// <param name="i_BatteryHoursToAdd">The number of hours to add to the battery charge.</param>
        public void ChargeBattery(float i_BatteryHoursToAdd)
        {
            if (m_BatteryHoursLeft + i_BatteryHoursToAdd <= m_MaxBatteryHours)
            {
                m_BatteryHoursLeft += i_BatteryHoursToAdd;
            }
            else
            {
                throw new ValueOutOfRangeException(m_BatteryHoursLeft + i_BatteryHoursToAdd, 0, m_MaxBatteryHours);
            }
        }

        protected ElectricVehicle(string i_ModelName, string i_LicensingNumber, List<Wheel> i_Wheels, float i_MaxBatteryHours)
            : base(i_ModelName, i_LicensingNumber, i_Wheels)
        {
            m_MaxBatteryHours = i_MaxBatteryHours;
        }

        public override Dictionary<string, string> GetAllProperties()
        {
            Dictionary<string, string> properties = base.GetAllProperties();

            properties.Add("Energy", "Electricity");
            properties.Add("Battery Hours Left", m_BatteryHoursLeft.ToString());
            properties.Add("Maximal Battery Hours", m_MaxBatteryHours.ToString());

            return properties;
        }
    }
}